/**
 * 
 */
package cen5501c.common;

import java.util.ArrayList;
import java.util.List;

/**
 * DELAY.
 * 
 * Response from the server to the GETDELAY protocol command. It is followed by
 * the status phrase: OK or ERROR. Example: <DELAY,OK>\n
 * 
 * @author Jiangyan Xu
 * 
 */
public class DelayCmd extends CmdBase {

	/**
	 * transmissionDelay: in nanosecs rtt, processingTime: in millisecs
	 * 
	 * @author Jiangyan Xu
	 * 
	 */
	public static class DelayStatistics {
		private long transmissionDelay;
		private long rtt;
		private long processingTime;

		/**
		 * @return the transmissionDelay
		 */
		public long getTransmissionDelay() {
			return transmissionDelay;
		}

		/**
		 * @return the rtt
		 */
		public long getRtt() {
			return rtt;
		}

		/**
		 * @return the processingTime
		 */
		public long getProcessingTime() {
			return processingTime;
		}

		/**
		 * @param transmissionDelay
		 * @param rtt
		 * @param processingTime
		 */
		public DelayStatistics(long transmissionDelay, long rtt,
				long processingTime) {
			this.transmissionDelay = transmissionDelay;
			this.rtt = rtt;
			this.processingTime = processingTime;
		}

		/*
		 * (non-Javadoc)
		 * 
		 * @see java.lang.Object#toString()
		 */
		@Override
		public String toString() {
			return "transmissionDelay: " + transmissionDelay
					+ " nanosecs, rtt: " + rtt + " millisecs, processingTime: "
					+ processingTime + " millisecs";
		}
	}

	public static enum DelayStatus {
		OK, ERROR
	}

	public static final String OPERATION = "DELAY";
	private DelayStatus delayStatus;

	/**
	 * Used by the client to summarize the statistics
	 */
	private DelayStatistics delayStatistics;

	/**
	 * @return the delayStatistics
	 */
	public DelayStatistics getDelayStatistics() {
		return delayStatistics;
	}

	/**
	 * @param delayStatistics
	 *            the delayStatistics to set
	 */
	public void setDelayStatistics(DelayStatistics delayStatistics) {
		this.delayStatistics = delayStatistics;
	}

	/**
	 * @return the oPERATION
	 */
	public static String getOPERATION() {
		return OPERATION;
	}

	/**
	 * @return the delayStatus
	 */
	public DelayStatus getDelayStatus() {
		return delayStatus;
	}

	/**
	 * @param delayStatus
	 *            the delayStatus to set
	 */
	public void setDelayStatus(DelayStatus delayStatus) {
		this.delayStatus = delayStatus;
	}

	/**
	 * @param args
	 * @throws Exception
	 */
	public DelayCmd(List<String> args) throws Exception {
		super(args);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cen5501c.common.CmdBase#fillArgs(java.util.List)
	 */
	@Override
	protected void fillArgs(List<String> args) throws Exception {
		delayStatus = DelayStatus.valueOf(args.get(0));
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cen5501c.common.CmdBase#getArgList()
	 */
	@Override
	public List<String> getArgList() {
		List<String> ret = new ArrayList<String>();
		ret.add(delayStatus.toString());
		return ret;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cen5501c.common.CmdBase#getOperation()
	 */
	@Override
	public String getOperation() {
		return OPERATION;
	}

}
